//
//  FirstDetailViewController.m
//  TakeHer
//
//  Created by Jupiter on 15/6/15.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "FirstDetailViewController.h"
#import "UIImageView+WebCache.h"
#import "AFNetworking.h"
@interface FirstDetailViewController ()
#define APP_HEIGHT [[UIScreen mainScreen]applicationFrame].size.height
#define APP_WIDTH [[UIScreen mainScreen]applicationFrame].size.width




@end

@implementation FirstDetailViewController

-(void)dataHandle
{
    self.str = @"http://api.breadtrip.com/destination/v3/?last_modified_since=0";
    // 对字符串进行UTF8转码
    _str = [_str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    
    // 创建对象
    AFHTTPRequestOperationManager *manger = [AFHTTPRequestOperationManager manager];
    
    manger.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/plain",@"text/json",@"application/json",@"text/javascript",@"text/html",nil];
    
    [manger GET:_str parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        //self.titleArr = [responseObject objectForKey:@"elements"];
        
        
        //[self.collectionView reloadData];
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        // 打印错误信息
        //        NSLog(@"%@", error);
        
    }];

}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, APP_WIDTH, APP_HEIGHT / 3)];
    [imageView setImageWithURLStr:_str];
    [self.view addSubview:imageView];
    [imageView release];
    
    UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, APP_HEIGHT / 3, APP_WIDTH, 25)];
    //titleLabel.backgroundColor = [UIColor yellowColor];
    [self.view addSubview:titleLabel];
    titleLabel.text = [self.titleDic objectForKey:@"name"];
    titleLabel.textAlignment = 1;
    titleLabel.textColor = [UIColor orangeColor];
    [titleLabel release];
    
    UITextView *information = [[UITextView alloc]initWithFrame:CGRectMake(5, APP_HEIGHT / 3 +25, APP_WIDTH - 10, APP_HEIGHT - (APP_HEIGHT / 3 +25)-64)];
    [self.view addSubview:information];
    //information.backgroundColor = [UIColor yellowColor];
    information.text = [self.titleDic objectForKey:@"description"];
    information.font = [UIFont systemFontOfSize:15];
    information.editable = NO;

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
